﻿using System;
using System.Linq;
using System.Xml.Linq;
using SharePointUtilitiesForDevelopers.Mapper;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace SharePointUtilitiesForDevelopers.Tests.Mapper
{
    /// <summary>
    /// Test class for <see cref="SharePointContentTypeMapper"/>.
    ///</summary>
    [TestClass]
    public class SharePointContentTypeMapperTest
    {
        [TestMethod]
        public void MapList_returns_correct_list()
        {
            var from = ServiceResponseTestHelper.LoadXml("GetContentTypes.xml");
            var target = ServiceLocator.Resolve<IMapper<XElement, SharePointContentType>>();
            var result = target.MapList(from);
            Console.WriteLine("{0} items", result.Count());
            Assert.IsTrue(result.Count() > 0);
        }

        [TestMethod]
        public void Map_returns_correct_object()
        {
            var from = ServiceResponseTestHelper.GetFirstElement("GetContentTypes.xml", "ContentType");
            var target = ServiceLocator.Resolve<IMapper<XElement, SharePointContentType>>();
            var result = target.Map(from);
            Assert.IsTrue(result != null);
        }
    }
}